<!DOCTYPE html>
<html lang="Zh-cn">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>主页</title>
	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
	<link rel="icon" href="favicon.ico" >
	<style type="text/css">
		.user{
			display: flex;
			width: 100%;
		}
	</style>
</head>
<body>

	<!-- daohangtiao -->
	<nav class="navbar navbar-default">
		<div class="container-fluid">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#a" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
				<a  class="navbar-brand" href="index.html">
				liuboy
				</a>
			</div>
			<a href="login.html" class="navbar-right navbar-link navbar-text loginUser">登陆/注册</a>
			<div id="a" class="collapse navbar-collapse">
			<ul class="nav navbar-nav">
			<li><a href="wenzhang.html">文章</a></li>
			<li><a href="fenxiang.html">分享</a></li>
			<li><a href="liuyan.html">留言</a></li>
			</ul>
			
		</div>

		</div>
	</nav>
	<!-- mianban -->
	<div class="panel panel-default">
		<div class="panel-heading">
			分享
		</div>
		<div class="panel-body">
			<div class="user">
			<img src="" style="max-width: 40px;max-height: 40px;" class="img1"><p class="username"></p>
			</div>
			<div class="fengxiangcontent"></div>
			<p class="time"></p>
			<div class="user">
			<img src="" style="max-width: 40px;max-height: 40px;" class="img2"><p class="username2"></p>
			</div>
			<div class="fengxiangcontent2"></div>
			<p class="time2"></p>
		</div>
	</div>
	
	<div class="panel panel-default">
		<div class="panel-heading">
			留言
		</div>
		<div class="panel-body">
			<form action="shangchuanliuyan.php" method="post" id="liuyanForm">
			<textarea name="content" placeholder="请在登陆后发表留言"></textarea>
			<div>
			<input type="button" value="去登陆" onclick="tologin()" id="submitbutton" class="btn btn-default">
			</div>
			</form>
			<hr/>
			<div class="yonghuliuyan">
			<img src="" style="max-width: 40px;max-height: 40px;" class="img2"><p class="username3"></p>
			</div>
			<div class="liuyancontent"></div>
			<p class="time3"></p>
			<div class="yonghuliuyan">
			<img src="" style="max-width: 40px;max-height: 40px;" class="img2"><p class="username4"></p>
			</div>
			<div class="liuyancontent2"></div>
			<p class="time4"></p>
		</div>
	</div>
</body>
	<script
  src="https://code.jquery.com/jquery-3.5.1.js"
  integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc="
  crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script type="text/javascript">

	$.get("lianxi.php",function(data){
	// $.get("http://liuboy.top/lianxi.php",function(data){
	
	var shuju =JSON.parse(data);
	console.log(shuju);
	console.log(data);
	$(".img1").attr("src",shuju[0].userimage);
	// $(".img").css("background-color","yellow");
	$(".username").html(shuju[0].username);
	$(".fengxiangcontent").html(shuju[0].content);
	$(".time").html(shuju[0].datetime);

	$(".img2").attr("src",shuju[1].userimage);
	// $(".img").css("background-color","yellow");
	$(".username2").html(shuju[1].username);
	$(".fengxiangcontent2").html(shuju[1].content);
	$(".time2").html(shuju[1].datetime);

});
	$.get("userid.php",function(id){
		var userData = JSON.parse(id);
		console.log(userData);
		$(".loginUser").replaceWith("<a href='putongyonghu.html' class='navbar-right navbar-link navbar-text loginUser'>欢迎您，"+userData[0].username+"</a><span class='glyphicon glyphicon-user navbar-right navbar-text' aria-hidden='true'></span>&nbsp<a href='zhuxiao.php' class='navbar-right navbar-link navbar-text'>注销</a>");
		$("textarea").attr("placeholder","你想对我说些什么嘛*-*");
		$("#submitbutton").attr("onclick","submitLiuYan()").attr("value","发表留言")
	
	});
			function tologin(){
			window.location="login.html"
		}
			function submitLiuYan(){
				$("#liuyanForm").submit()
			}
	$.get("liuyanList.php",function(liuyan){
		var liuyan = JSON.parse(liuyan)
		console.log(liuyan)
		$(".username3").html(liuyan[0].username)
		$(".liuyancontent").html(liuyan[0].content)
		$(".time3").html(liuyan[0].time)
		$(".username4").html(liuyan[1].username)
		$(".liuyancontent2").html(liuyan[1].content)
		$(".time4").html(liuyan[1].time)	
	})
		

</script>
</html>